package com.qianyu.thread;

import java.util.*;

class MaxQueue {
    private Queue<Integer> queue = new LinkedList<>();
    private TreeSet<Integer> set = new TreeSet<>();

    public MaxQueue() {
    }

    public int max_value() {
        if (queue.size() == 0) {
            return -1;
        }
        return set.last();
    }

    public void push_back(int value) {
        set.add(value);
        queue.add(value);
    }

    public int pop_front() {
        if (queue.size() == 0) {
            return -1;
        }
        Integer val = queue.poll();
        set.remove(val);
        return val;
    }
}

public class Solution {
    public static void main(String[] args) {

    }
}
